 package handling.login;

 import java.io.File;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import provider.MapleData;
 import provider.MapleDataProvider;
 import provider.MapleDataProviderFactory;
 import provider.MapleDataTool;
 import tools.Triple;


 public class LoginInformationProvider
 {
   private static LoginInformationProvider instance;
/*  18 */   protected final List<String> ForbiddenName = new ArrayList<>();
/*  19 */   protected final List<String> Curse = new ArrayList<>();
/*  20 */   protected final List<Integer> makeCharInfoItemIds = new ArrayList<>();

/*  22 */   protected final Map<Triple<Integer, Integer, Integer>, List<Integer>> makeCharInfo = new HashMap<>();










   protected LoginInformationProvider() {
/*  34 */     String WZpath = System.getProperty("wzpath");
/*  35 */     MapleDataProvider prov = MapleDataProviderFactory.getDataProvider(new File(WZpath + "/Etc.wz"));
/*  36 */     MapleData nameData = prov.getData("ForbiddenName.img");
/*  37 */     for (MapleData data : nameData.getChildren()) {
/*  38 */       this.ForbiddenName.add(MapleDataTool.getString(data));
     }
/*  40 */     this.ForbiddenName.add("落叶无痕");
/*  41 */     this.ForbiddenName.add("HiredMerch");
/*  42 */     nameData = prov.getData("Curse.img");
/*  43 */     for (MapleData data : nameData.getChildren()) {
/*  44 */       this.Curse.add(MapleDataTool.getString(data).split(",")[0]);
/*  45 */       this.ForbiddenName.add(MapleDataTool.getString(data).split(",")[0]);
     }
/*  47 */     MapleData infoData = prov.getData("MakeCharInfo.img");

/*  49 */     for (MapleData dat : infoData) {
/*  50 */       int type; if (dat.getName().endsWith("Male") || dat.getName().endsWith("Female") || dat.getName().endsWith("Adventurer") || dat.getName().equals("10112_Dummy")) {
         continue;
       }

/*  54 */       if (dat.getName().equals("000_1")) {
/*  55 */         type = (JobType.getById(1)).type;
/*  56 */       } else if (dat.getName().equals("3001_Dummy")) {
/*  57 */         type = (JobType.getById(6)).type;
/*  58 */       } else if (dat.getName().equals("000_3")) {
/*  59 */         type = (JobType.getById(22)).type;
       } else {
/*  61 */         type = (JobType.getById(Integer.parseInt(dat.getName()))).type;
       }

/*  64 */       for (MapleData d : dat) {
         int gender;
/*  66 */         if (d.getName().equals("male") || d.getName().startsWith("male")) {
/*  67 */           gender = 0;
/*  68 */         } else if (d.getName().equals("female") || d.getName().startsWith("female")) {
/*  69 */           gender = 1;
         } else {
           continue;
         }
/*  73 */         for (MapleData da : d) {

/*  75 */           Triple<Integer, Integer, Integer> key = new Triple(Integer.valueOf(gender), Integer.valueOf(Integer.parseInt(da.getName())), Integer.valueOf(type));
/*  76 */           List<Integer> our = this.makeCharInfo.computeIfAbsent(key, k -> new ArrayList());
/*  77 */           for (MapleData dd : da) {
/*  78 */             if (!dd.getName().equals("name")) {
/*  79 */               our.add(Integer.valueOf(MapleDataTool.getInt(dd, -1)));
             }
           }
         }
       }
     }

/*  86 */     MapleData uA = infoData.getChildByPath("UltimateAdventurer");
/*  87 */     for (MapleData dat : uA) {
/*  88 */       Triple<Integer, Integer, Integer> key = new Triple(Integer.valueOf(-1), Integer.valueOf(Integer.parseInt(dat.getName())), Integer.valueOf(JobType.终极冒险家.type));
/*  89 */       List<Integer> our = this.makeCharInfo.computeIfAbsent(key, k -> new ArrayList());
/*  90 */       for (MapleData d : dat) {
/*  91 */         our.add(Integer.valueOf(MapleDataTool.getInt(d, -1)));
       }
     }


/*  96 */     for (MapleData data : infoData) {
/*  97 */       if (data.getName().equalsIgnoreCase("UltimateAdventurer")) {
         continue;
       }
/* 100 */       if (data.getName().endsWith("Male") || data.getName().endsWith("Female")) {
/* 101 */         for (MapleData dat : data) {
/* 102 */           for (MapleData da : dat) {
/* 103 */             int itemId = MapleDataTool.getInt(da, -1);
/* 104 */             if (itemId > 1000000 && !this.makeCharInfoItemIds.contains(Integer.valueOf(itemId)))
/* 105 */               this.makeCharInfoItemIds.add(Integer.valueOf(itemId)); 
           }
         }
         continue;
       }
/* 110 */       for (MapleData dat : data) {
/* 111 */         if (dat.getName().startsWith("male") || dat.getName().startsWith("female")) {
/* 112 */           for (MapleData da : dat) {
/* 113 */             for (MapleData dd : da) {
/* 114 */               if (!dd.getName().equals("name")) {
/* 115 */                 int itemId = MapleDataTool.getInt(dd, -1);
/* 116 */                 if (itemId > 1000000 && !this.makeCharInfoItemIds.contains(Integer.valueOf(itemId))) {
/* 117 */                   this.makeCharInfoItemIds.add(Integer.valueOf(itemId));
                 }
               }
             }
           }
         }
       }
     }
   }


   public static LoginInformationProvider getInstance() {
/* 129 */     if (instance == null) {
/* 130 */       instance = new LoginInformationProvider();
     }
/* 132 */     return instance;
   }




   public boolean isForbiddenName(String in) {
/* 139 */     for (String name : this.ForbiddenName) {
/* 140 */       if (in.toLowerCase().contains(name.toLowerCase())) {
/* 141 */         return true;
       }
     }
/* 144 */     return false;
   }




   public boolean isCurseMsg(String in) {
/* 151 */     for (String name : this.Curse) {
/* 152 */       if (in.toLowerCase().contains(name.toLowerCase())) {
/* 153 */         return true;
       }
     }
/* 156 */     return false;
   }

   public boolean isEligibleItem(int gender, int val, int job, int item) {
/* 160 */     if (item < 0) {
/* 161 */       return false;
     }
/* 163 */     Triple<Integer, Integer, Integer> key = new Triple(Integer.valueOf(gender), Integer.valueOf(val), Integer.valueOf(job));
/* 164 */     List<Integer> our = this.makeCharInfo.get(key);
/* 165 */     return (our != null && our.contains(Integer.valueOf(item)));
   }




   public boolean isEligibleItem(int itemId) {
/* 172 */     return (itemId >= 0 && (itemId == 0 || this.makeCharInfoItemIds.contains(Integer.valueOf(itemId))));
   }
 }


/* Location:              C:\PGX\Server.jar!\handling\login\LoginInformationProvider.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */